/**
 */
package fUML.Semantics.Classes.Kernel.impl;

import fUML.Semantics.Classes.Kernel.KernelPackage;

import fUML.Semantics.CommonBehaviors.BasicBehaviors.Execution;
import fUML.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;

import fUML.Semantics.CommonBehaviors.Communications.CommunicationsPackage;
import fUML.Semantics.CommonBehaviors.Communications.EventAccepter;
import fUML.Semantics.CommonBehaviors.Communications.ObjectActivation;
import fUML.Semantics.CommonBehaviors.Communications.SignalInstance;

import fUML.Syntax.Classes.Kernel.Classifier;
import fUML.Syntax.Classes.Kernel.Operation;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Object</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fUML.Semantics.Classes.Kernel.impl.ObjectImpl#getObjectActivation <em>Object Activation</em>}</li>
 *   <li>{@link fUML.Semantics.Classes.Kernel.impl.ObjectImpl#getTypes <em>Types</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ObjectImpl extends ExtensionalValueImpl implements fUML.Semantics.Classes.Kernel.Object {
	/**
	 * The cached value of the '{@link #getObjectActivation() <em>Object Activation</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getObjectActivation()
	 * @generated
	 * @ordered
	 */
	protected ObjectActivation objectActivation;

	/**
	 * The cached value of the '{@link #getTypes() <em>Types</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTypes()
	 * @generated
	 * @ordered
	 */
	protected EList<Classifier> types;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ObjectImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return KernelPackage.Literals.OBJECT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ObjectActivation getObjectActivation() {
		return objectActivation;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetObjectActivation(ObjectActivation newObjectActivation, NotificationChain msgs) {
		ObjectActivation oldObjectActivation = objectActivation;
		objectActivation = newObjectActivation;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, KernelPackage.OBJECT__OBJECT_ACTIVATION, oldObjectActivation, newObjectActivation);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setObjectActivation(ObjectActivation newObjectActivation) {
		if (newObjectActivation != objectActivation) {
			NotificationChain msgs = null;
			if (objectActivation != null)
				msgs = ((InternalEObject)objectActivation).eInverseRemove(this, CommunicationsPackage.OBJECT_ACTIVATION__OBJECT, ObjectActivation.class, msgs);
			if (newObjectActivation != null)
				msgs = ((InternalEObject)newObjectActivation).eInverseAdd(this, CommunicationsPackage.OBJECT_ACTIVATION__OBJECT, ObjectActivation.class, msgs);
			msgs = basicSetObjectActivation(newObjectActivation, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, KernelPackage.OBJECT__OBJECT_ACTIVATION, newObjectActivation, newObjectActivation));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Classifier> getTypes() {
		if (types == null) {
			types = new EObjectResolvingEList<fUML.Syntax.Classes.Kernel.Classifier>(fUML.Syntax.Classes.Kernel.Class.class, this, KernelPackage.OBJECT__TYPES);
		}
		return types;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void startBehavior(fUML.Syntax.Classes.Kernel.Class classifier, EList<ParameterValue> inputs) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Execution dispatch(Operation operation) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void send(SignalInstance signalInstance) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void register(EventAccepter accepter) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unregister(EventAccepter accepter) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case KernelPackage.OBJECT__OBJECT_ACTIVATION:
				if (objectActivation != null)
					msgs = ((InternalEObject)objectActivation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - KernelPackage.OBJECT__OBJECT_ACTIVATION, null, msgs);
				return basicSetObjectActivation((ObjectActivation)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case KernelPackage.OBJECT__OBJECT_ACTIVATION:
				return basicSetObjectActivation(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case KernelPackage.OBJECT__OBJECT_ACTIVATION:
				return getObjectActivation();
			case KernelPackage.OBJECT__TYPES:
				return getTypes();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case KernelPackage.OBJECT__OBJECT_ACTIVATION:
				setObjectActivation((ObjectActivation)newValue);
				return;
			case KernelPackage.OBJECT__TYPES:
				getTypes().clear();
				getTypes().addAll((Collection<? extends fUML.Syntax.Classes.Kernel.Class>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case KernelPackage.OBJECT__OBJECT_ACTIVATION:
				setObjectActivation((ObjectActivation)null);
				return;
			case KernelPackage.OBJECT__TYPES:
				getTypes().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case KernelPackage.OBJECT__OBJECT_ACTIVATION:
				return objectActivation != null;
			case KernelPackage.OBJECT__TYPES:
				return types != null && !types.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //ObjectImpl
